<?php
	mysql_connect("sql.free.fr", "eclipse60", ">2hvxSoc");
	mysql_select_db("eclipse60");
	
	$req = mysql_query("SELECT * FROM visites WHERE ip='".$_SERVER['REMOTE_ADDR']."'");
	$data = mysql_fetch_array($req);
	
	if ($data == false)
	{
		mysql_query("INSERT INTO visites VALUES('', '".$_SERVER['REMOTE_ADDR']."', '".time()."', '1')");
	}
	else
	{
		mysql_query("UPDATE visites SET timestamp='".time()."', nbre='".($data['nbre'] + 1)."' WHERE ip='".$_SERVER['REMOTE_ADDR']."'");
	}
	
	$req = mysql_query("SELECT * FROM visites_online WHERE ip='".$_SERVER['REMOTE_ADDR']."'");
	$data = mysql_fetch_array($req);
	
	if ($data == false)
	{
		mysql_query("INSERT INTO visites_online VALUES('', '".$_SERVER['REMOTE_ADDR']."', '".time()."')");
	}
	else
	{
		mysql_query("UPDATE visites_online SET timestamp='".time()."' WHERE ip='".$_SERVER['REMOTE_ADDR']."'");
	}
	
	$req = mysql_query("SELECT * FROM visites_online");
	
	while ($data = mysql_fetch_array($req))
	{
		if (time() > ($data['timestamp'] + (5 * 60)))
		{
			mysql_query("DELETE FROM visites_online WHERE id='".$data['id']."'");
		}
	}
	
	mysql_close();
?>